/*
 * Project Beknyou
 * Copyright (c) 2010-2011 Saint Paul College, All Rights Reserved
 * Redistributions in source code form must reproduce the above
 * Copyright and this condition.
 * The contents of this file are subject to the GNU General Public
 * License, Version 2 (the "License"); you may not use this file
 * except in compliance with the License. A copy of the License is
 * available at http://www.opensource.org/licenses/gpl-license.php.
 */
package com.benkyou.server.listeners;

import com.benkyou.common.messages.ChatClientMessage;
import com.benkyou.server.GameServer;
import com.jme3.network.HostedConnection;
import com.jme3.network.Message;
import com.jme3.network.MessageListener;

/**
 *
 * @author Austin Allman
 */
public class ChatMessageListener implements MessageListener<HostedConnection> {

    private GameServer gameServer;

    public ChatMessageListener(GameServer gameServer) {
        this.gameServer = gameServer;

    }

    public void messageReceived(HostedConnection source, Message m) {
        if (m instanceof ChatClientMessage) {
            ChatClientMessage chatClientMessage = (ChatClientMessage) m;
           /* if(chatClientMessage.isNewUser()){
              chatClientMessage.setUUID((String)source.getAttribute("UUID"));
              gameServer.getMyServer().broadcast(chatClientMessage);  
            }*/
            gameServer.getMyServer().broadcast(chatClientMessage.setReliable(false));

        }
    }
}
